<?php
class Adherent_m extends Model{
      function Adherent_m(){
          parent::Model();
          $this->load->database();
      }
    function count_adherent(){
     $this->db->select();
        $this->db->from('inscription');
        $this->db->where(array('ad'=>'1'));
        $query =$this->db->get();
     return $query->num_rows();
    }
    function get_adherent($per_page, $offset){
      $this->db->select();
        $this->db->from('inscription');
        $this->db->where(array('ad'=>'1'));
        $this->db->order_by('date_ins desc');
        $this->db->limit($per_page,$offset);
         $query =$this->db->get();
        return $query->result_array();
    }
     function count_inscription(){
      $this->db->select();
        $this->db->from('inscription');
        $this->db->where(array('ad'=>'0'));
        $query =$this->db->get();
     return $query->num_rows();
    }
    function get_inscription($per_page, $offset){
        $this->db->select();
        $this->db->from('inscription');
        $this->db->where(array('ad'=>'0'));
        $this->db->order_by('date_ins desc');
        $this->db->limit($per_page,$offset);
         $query =$this->db->get();
      
        return $query->result_array();
    }
     function get_sports($string){
        $this->db->select();
        $this->db->from('sports');
        $this->db->where('id in ('.$string.')');
         $query =$this->db->get();
        return $query->result_array();
   }
   function get_recherche($string){
        $this->db->select();
        $this->db->from('recherche');
        $this->db->where('id in ('.$string.')');
         $query =$this->db->get();
        return $query->result_array();
   }
   function get_detail_client($id){
        $this->db->select('inscription.*,secteur.nom as secteurnom');
        $this->db->from('inscription');
        $this->db->join('secteur','secteur.id=inscription.secteur','left');
        $this->db->where(array('inscription.id'=>$id));
        $query =$this->db->get();

        return $query->row_array();
    }
    function update_client($data, $id){
       return $this->db->update('inscription',$data,array('id'=>$id));
    }
    function desactiver_client($id){
       return $this->db->update('inscription',array('ad'=>'0','date_debut'=>'','date_fin'=>''),array('id'=>$id));
    }

     function get_contact($per_page,$offset){
        $this->db->select();
        $this->db->from('contact');
        $this->db->limit($per_page,$offset);
        $this->db->order_by('id','DESC');
        $query=$this->db->get();
        return $query->result_array();
     }
     function delete_contact($id){
            return $this->db->delete('contact',array('id'=>$id));   
     }
     function get_detail_contact($id){
        $this->db->select();
        $this->db->from('contact');
        $this->db->where(array('contact.id'=>$id));
        $query =$this->db->get();
        return $query->row_array();
    }
     function get_mail($id){
           $this->db->select();
           $this->db->from('mail_auto');
            $this->db->where("id",$id);
           $query=$this->db->get();
           return $query->row_array();
     }

}
?>